package com.seres.util;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

public class AnnotationUtil {

    public static boolean checkAnn(Method method, Class<? extends Annotation> cls) {
        return method.isAnnotationPresent(cls);
    }

    public static boolean checkAnn(Class<?> cla, Class<? extends Annotation> cls) {
        return cla.isAnnotationPresent(cls);
    }


    public static String getApiMode(Class<?> cls) {
        if (checkAnn(cls, Api.class)) {
            return cls.getAnnotation(Api.class).value();
        }
        return cls.getName();
    }

    public static String getApiPro(Method method) {
        if (checkAnn(method, ApiOperation.class)) {
            return method.getAnnotation(ApiOperation.class).value();
        }
        return method.getName();
    }

}
